<template>
  <div class="max">
    <div class="max_left">
      <!-- 企业信息 -->
      <div class="maxleftbox"
           id="top1">
        <div class="maxleft_title">
          企业信息
          <i>适用于企业，个体工商户，事业单位等，通过营业执照，组织机构代码等相关资质进行认证</i>
        </div>
        <div class="maxleft_title1">
          <a-form-model ref="ruleForm3"
                        :model="form"
                        :rules="rules"
                        :label-col="labelCol2"
                        :wrapper-col="wrapperCol2">
            <a-row>
              <a-col :span="12"><span>企业简称：
                  <a-input v-model="form.shortName"
                           placeholder="请输入企业简称"
                           style="width:240px;margin-left: 16px;" />
                </span></a-col>
              <a-col :span="12"><span>企业名称： <i>{{ enterpriseInformationArr.name }}</i></span></a-col>
            </a-row>
            <a-row>
              <a-col :span="12"><span>企业类型：
                  <i style="margin-left:20px">{{ enterpriseInformationArr.entTypeName }}</i>
                </span></a-col>
              <a-col :span="12"><span>法定代表人：
                  <i>{{ enterpriseInformationArr.legalPerson }}</i></span></a-col>
            </a-row>
            <a-row>
              <a-col :span="12"><span>营业期限：
                  <i style="margin-left:20px">{{ enterpriseInformationArr.termStart }} -
                    {{ enterpriseInformationArr.termEnd }}</i></span></a-col>
              <a-col :span="12"><span>注册资本（万）
                  <i>{{ enterpriseInformationArr.regCapital }}</i></span></a-col>
            </a-row>
            <a-row>
              <a-col :span="12"><span>成立日期：
                  <i style="margin-left:20px">{{ enterpriseInformationArr.foundDate }}</i></span></a-col>
              <a-col :span="12"><span>注册国家/地区：
                  <i>{{ enterpriseInformationArr.province }}</i></span></a-col>
            </a-row>
            <a-row>
              <a-col :span="24"><span>注册地址：
                  <i style="margin-left:20px">{{ enterpriseInformationArr.address }}</i></span>
              </a-col>
            </a-row>
            <a-row v-if="currentType === 2"
                   style="margin-bottom:10px">
              <a-col :span="12">
                <span>经营品牌 :
                  <a-select placeholder="请选择经营品牌"
                            v-model="form.brandId"
                            style="width: 240px; height: 32px;margin-left: 22px;"
                            @change="productHandleChange">
                    <a-select-option v-for="item in productList"
                                     :value="item.id"
                                     :key="item.id">
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                </span>
                <!-- <a-form-model-item label="经营品牌"
                                   prop="brandId"
                                   style="margin-bottom: 0">
                  <a-select placeholder="请选择经营品牌"
                            v-model="form.brandId"
                            style="width: 240px; height: 28px"
                            @change="productHandleChange">
                    <a-select-option v-for="item in productList"
                                     :value="item.id"
                                     :key="item.id">
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                </a-form-model-item> -->
                <span> </span>
              </a-col>
            </a-row>
            <a-row v-if="currentType === 3">
              <a-col :span="24"
                     style="position: relative; padding-top: 5px">
                <span style="position: absolute; top: -1px">经营范围：</span>
                <i class="scope">{{ enterpriseInformationArr.scope }}</i>
              </a-col>
            </a-row>
            <a-row style="margin-bottom:10px">
              <a-col :span="12">
                <span>法人联系方式 :
                  <a-input v-model="form.legalPersonMobile"
                           placeholder="请输入法人代表联系方式"
                           style="width:240px" />
                </span>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="24"
                     style="position: relative; padding-top: 5px">
                <span style="position: absolute; top: -1px">法人身份证:</span>
                <div style="margin-left:82px">
                  <div class="photos4">
                    <div class="avatars"><img src="../../../assets/image/enter/gb.png"
                           alt=""
                           v-show="form.idCardFrontPicId"
                           @click="delImage('idCardFrontPicId')"></div>
                    <div class="upload-image-contain"
                         @click="$imagePreview(previewUrl + form.idCardFrontPicId)"
                         v-if="form.idCardFrontPicId">
                      <img class="uppload-image"
                           :src="previewUrl + form.idCardFrontPicId"
                           alt="文件丢失，请重新上传" />
                    </div>
                    <a-upload name="file"
                              list-type="picture-card"
                              class="avatar-uploader"
                              v-else
                              :show-upload-list="false"
                              :action="uploadUrl"
                              :before-upload="beforeUpload"
                              @change="idCardFrontPicChange">
                      <div>
                        <img src="../../../assets/image/enter/bz.png"
                             alt="">
                      </div>
                    </a-upload>
                    <p>头像面</p>
                  </div>
                  <div class="photos5">
                    <div class="avatars"><img src="../../../assets/image/enter/gb.png"
                           alt=""
                           v-show="form.idCardBackPicId"
                           @click="delImage('idCardBackPicId')"></div>
                    <div class="upload-image-contain"
                         @click="$imagePreview(previewUrl + form.idCardBackPicId)"
                         v-if="form.idCardBackPicId">
                      <img class="uppload-image"
                           :src="previewUrl + form.idCardBackPicId"
                           alt="文件丢失，请重新上传" />
                    </div>
                    <a-upload name="file"
                              list-type="picture-card"
                              class="avatar-uploader"
                              :show-upload-list="false"
                              v-else
                              :action="uploadUrl"
                              :before-upload="beforeUpload"
                              @change="idCardBackPicChange">
                      <div>
                        <img src="../../../assets/image/enter/bz2.png"
                             alt="">
                      </div>
                    </a-upload>
                    <p>国徽面</p>
                  </div>
                  <div class="photos3">
                    <div class="avatars"><img src="../../../assets/image/enter/gb.png"
                           alt=""
                           v-show="form.businessLicensePicId"
                           @click="delImage('businessLicensePicId')"></div>
                    <div class="upload-image-contain"
                         @click="$imagePreview(previewUrl + form.businessLicensePicId)"
                         v-if="form.businessLicensePicId">
                      <img class="uppload-image"
                           :src="previewUrl + form.businessLicensePicId"
                           alt="文件丢失，请重新上传" />
                    </div>
                    <a-upload name="file"
                              list-type="picture-card"
                              class="avatar-uploader"
                              :show-upload-list="false"
                              v-else
                              :action="uploadUrl"
                              :before-upload="beforeUpload"
                              @change="businessLicensePicChange">
                      <div>
                        <img src="../../../assets/image/enter/pic33.png"
                             alt=""
                             width="152"
                             height="68">
                      </div>
                    </a-upload>
                    <p>法人营业执照</p>
                  </div>
                </div>
              </a-col>
            </a-row>
          </a-form-model>
        </div>
      </div>
      <!-- 业务信息 -->
      <div class="maxleftbox max_logo"
           id="top2"
           v-if="currentType === 3">
        <div class="maxleft_title">
          业务信息
          <i>提示：业务信息将会出现在您的首页上，丰富的内容将有助于提高您的资质，便于更多企业快速阅览，促进交易</i>
        </div>
        <div class="maxleft_title1">
          <a-form-model ref="ruleForm1"
                        :model="form"
                        :rules="rules"
                        :label-col="labelCol"
                        :wrapper-col="wrapperCol">
            <a-row>
              <a-col :span="24">
                <a-form-model-item label="组织类型"
                                   prop="orgType">
                  <a-radio-group name="radioGroup"
                                 v-model="form.orgType">
                    <a-radio :value="1">汽配商</a-radio>
                    <a-radio :value="2">品牌一级代理商</a-radio>
                    <a-radio :value="3">品牌二级代理商</a-radio>
                  </a-radio-group>
                </a-form-model-item>
              </a-col>
            </a-row>

            <a-row>
              <a-col :span="24">
                <a-form-model-item label="主营品类"
                                   prop="masterCategory">
                  <!-- <a-tree-select v-model="value"
                                 style="width: 100%"
                                 :tree-data="treeData"
                                 :replaceFields="replaceFields"
                                 tree-checkable
                                 :show-checked-strategy="SHOW_PARENT"
                                 @change="onchanges"
                                 search-placeholder="Please select" /> -->
                  <a-radio-group name="radioGroup"
                                 v-model="form.masterCategory">
                    <a-radio :value="1">配件</a-radio>
                    <a-radio :value="2">轮胎</a-radio>
                    <a-radio :value="3">用品</a-radio>
                    <a-radio :value="4">服务</a-radio>
                  </a-radio-group>
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="24">
                <a-form-model-item label="辅营品类"
                                   prop="assistCategory">
                  <a-radio-group name="radioGroup"
                                 v-model="form.assistCategory">
                    <a-radio :value="1">配件</a-radio>
                    <a-radio :value="2">轮胎</a-radio>
                    <a-radio :value="3">用品</a-radio>
                    <a-radio :value="4">服务</a-radio>
                  </a-radio-group>
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="24">
                <a-form-model-item label="送货服务范围"
                                   prop="deliveries">
                  <multiple-select :list.sync="servicesArea"
                                   v-model="deliveries"
                                   @child="getServicesAreaChild"></multiple-select>
                </a-form-model-item>
              </a-col>
              <a-col :span="24"
                     style="position: relative">
                <a-form-model-item label="公司logo"
                                   prop="logo">
                  <a-upload name="file"
                            list-type="picture-card"
                            class="avatar-uploader"
                            :show-upload-list="false"
                            :action="uploadUrl"
                            :before-upload="beforeUpload"
                            @change="handleChange">
                    <img v-if="form.logo"
                         :src="
                        form.logo.indexOf('http') === -1
                          ? previewUrl + form.logo
                          : form.logo
                      "
                         alt="文件丢失，请重新上传"
                         width="23px" />
                    <div v-else>
                      <a-icon :type="loading ? 'loading' : 'plus'" />
                    </div>
                  </a-upload>
                  <div class="uploadimg">上传格式：*.jpg，*.png，*jpeg，</div>
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="24">
                <a-form-model-item label="公司简介">
                  <a-textarea v-model="form.introduction"
                              placeholder="请输入公司简介"
                              :rows="4" />
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-form-model>
        </div>
      </div>
      <!-- 联系人信息 -->
      <div class="maxleftbox"
           id="top3">
        <div class="maxleft_title">
          联系人信息
          <i>提示：真实的联系人信息便于合作企业快速联系您，至少需要维护一条默认联系人</i>
          <div class="addbutton"
               @click="addlinkman()">新增联系人
          </div>
        </div>
        <div class="maxleftbox_box">
          <div class="box_li"
               v-for="(item, index) in form.tenantContacts"
               :key="index">
            <div class="box_litop">
              <div class="box_litop_left">
                <p>{{ item.contactName }}</p>
                <p>{{ item.contactMobile }}</p>
              </div>
              <div class="box_litop_right">
                <span v-if="item.beDefault">已默认</span>
                <i v-if="!item.beDefault"
                   @click="clickDefault(index)">默认 </i>
                <i @click="editLinkman(item, index)">修改</i>
                <i v-if="!item.beDefault"
                   @click="delDefault(index)">删除</i>
              </div>
            </div>
            <div class="box_bottom">
              <div class="bottom_left"
                   style="width：100%">
                <p>
                  邮箱：<span>{{ item.contactEmail }}</span>
                </p>
                <p>
                  系统消息：<span v-if="item.receiveSysMsg == true"> 接收</span> <span v-if="item.receiveSysMsg == false"> 不接收</span>
                </p>
                <p style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;width:280px">
                  地址：<span>{{item.province}} {{item.city}} {{item.district}} {{item.street}} {{item.detailAddr}}</span>
                </p>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 地址 -->
      <div class="maxleftbox"
           id="top4">
        <div class="maxleft_title">
          地址
          <i>提示：您的企业可能在多地拥有工厂/公司，建议维护完整信息，展示贵司规模。</i>
          <div class="addbutton"
               @click="addAddress()">新增收货地址
          </div>
        </div>
        <div class="maxleftbox_box">
          <div class="box_li"
               style="height: 134px"
               v-for="(item, index) in form.tenantAddresses"
               :key="index">
            <div class="box_litop"
                 style="height: 64px">
              <div class="box_litop_dress">
                <p>
                  {{ item.province }} {{ item.city }} {{ item.district }}
                  {{ item.street }} {{ item.detailAddr }}
                </p>
              </div>
              <!-- <div class="box_litop_right" style="margin-top:0px"> 15920365421</div> -->
            </div>
            <div class="box_bottom">
              <div class="bottom_left">
                <div class="bottom_left">
                  <p class="addressbz">地址备注：{{ item.comment }}</p>
                  <p>
                    邮政编码：<span>{{ item.postCode }}</span>
                  </p>
                </div>
              </div>
              <div class="dizhi"
                   style="right: 0; bottom: 12px">
                <i v-if="item.beenDefault"
                   style="color: #999">已默认</i>
                <i v-if="!item.beenDefault"
                   @click="clickBeenDefault(index)">默认
                </i>
                <i @click="editAddress(item, index)">修改</i>
                <i v-if="!item.beenDefault"
                   @click="delAddress(index)">删除</i>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 银行卡信息 -->
      <div class="maxleftbox"
           id="top5"
           v-if="this.currentType === 3">
        <div class="maxleft_title">
          银行卡信息
          <i>提示：维护账号信息，后续您向合作企业提供付款账号时，可快速复制。</i>
          <div class="addbutton"
               @click="addbankcard()">新增银行卡
          </div>
        </div>
        <div class="maxleftbox_box">
          <div class="box_li"
               style="height: 140px"
               v-for="(item, index) in form.tenantBanks"
               :key="index">
            <div class="box_litop"
                 style="
                height: 46px;
                padding: 14px 0;
                color: #333;
                line-height: 17px;
              ">
              <div class="box_litop_left">
                <p>{{ item.bankName }}</p>
              </div>
              <div class="box_litop_right"
                   style="
                  margin-top: 0px;
                  font-family: PingFangSC, PingFangSC-Medium;
                  font-weight: 500;
                ">
                尾号{{ item.tail }}
              </div>
            </div>
            <div class="box_bottom">
              <div class="bottom_left">
                <p>
                  开户行：<span>{{ item.account }}</span>
                </p>
                <p>
                  帐号名称：<span>{{ item.accountName }}</span>
                </p>
                <p style="opacity: 0">
                  帐号名称：<span>{{ item.accountName }}</span>
                </p>
              </div>
              <div class="dizhi"
                   style="right: 0; bottom: 12px">
                <i v-if="item.master"
                   style="color: #999">主账户</i>
                <i v-if="!item.master"
                   @click="clickMaster(index)">设置主账户
                </i>
                <i @click="editBankCard(item, index)">修改</i>
                <i v-if="!item.master"
                   @click="delMaster(index)">删除</i>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 开票信息 -->
      <div class="maxleftbox max_logo"
           id="top6">
        <div class="maxleft_title">
          开票信息
          <i>非常重要：开票信息要保证发票真实有效，请维护准确完整的开票信息。</i>
        </div>
        <div class="maxleft_title1 invoice-info">
          <a-form-model ref="ruleForm"
                        :model="form"
                        :rules="rules"
                        :label-col="labelCol1"
                        :wrapper-col="wrapperCol1">
            <a-row>
              <a-col :span="12">
                <a-form-model-item label="发票抬头"
                                   prop="tenantInvoice.title">
                  <a-input v-model="form.tenantInvoice.title"
                           placeholder="请输入发票抬头" />
                </a-form-model-item>
              </a-col>
              <a-col :span="12">
                <a-form-model-item label="税务登记号"
                                   prop="tenantInvoice.taxRegNo">
                  <a-input v-model="form.tenantInvoice.taxRegNo"
                           placeholder="请输入税务登记号" />
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="12">
                <a-form-model-item label="开户行"
                                   prop="tenantInvoice.bankAccount">
                  <a-input v-model="form.tenantInvoice.bankAccount"
                           placeholder="请输入开户行" />
                </a-form-model-item>
              </a-col>
              <a-col :span="12">
                <a-form-model-item label="开户行帐号"
                                   prop="tenantInvoice.accountName">
                  <a-input v-model="form.tenantInvoice.accountName"
                           placeholder="请输入开户行帐号" />
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="12">
                <a-form-model-item label="税务登记地址"
                                   prop="tenantInvoice.taxRegAddr">
                  <a-input v-model="form.tenantInvoice.taxRegAddr"
                           placeholder="请输入税务登记地址" />
                </a-form-model-item>
              </a-col>
              <a-col :span="12">
                <a-form-model-item label="税务登记电话"
                                   prop="tenantInvoice.taxRegTel">
                  <a-input v-model="form.tenantInvoice.taxRegTel"
                           placeholder="请输入税务登记电话" />
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="12">
                <a-form-model-item label="收票人邮箱"
                                   prop="tenantInvoice.acceptEmail">
                  <a-input v-model="form.tenantInvoice.acceptEmail"
                           placeholder="请输入收票人邮箱" />
                </a-form-model-item>
              </a-col>
              <a-col :span="12">
                <a-form-model-item label="收票人手机号"
                                   prop="tenantInvoice.acceptMobile">
                  <a-input v-model="form.tenantInvoice.acceptMobile"
                           placeholder="请输入收票人手机号" />
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="12">
                <a-form-model-item label="所在地区"
                                   prop="tenantInvoice.optionsA">
                  <a-cascader :options="CityArray"
                              :value="form.tenantInvoice.optionsA"
                              :load-data="loadData"
                              change-on-select
                              @change="onChangeAddress"
                              placeholder="请选择地址" />
                </a-form-model-item>
              </a-col>
              <a-col :span="12">
                <a-form-model-item label="地址详情"
                                   prop="tenantInvoice.acceptAddr">
                  <a-input v-model="form.tenantInvoice.acceptAddr"
                           placeholder="请输入地址详情" />
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-form-model>
        </div>
      </div>

      <!-- 公司附件 -->
      <!-- <div class="maxleftbox"
           id="top8">
        <div class="maxleft_title">
          公司附件
          <i>非常重要：您可在此处上传各类经营/质量及各类许可证信息，便于贵司的资质认可，营业执照必须上传</i>
          <div class="addbutton"
               @click="addfileupload()">新增附件
          </div>
        </div>
        <div class="maxleftbox_box">
          <div class="box_li"
               style="height: 102px; position: relative"
               v-for="(item, index) in form.tenantAttachments"
               :key="index">
            <img class="box_fujianimg"
                 :src="previewUrl + item.attachmentId"
                 alt=""
                 v-if="
                item.fileType === 'jpg' ||
                item.fileType === 'png' ||
                item.fileType === 'jpeg'
              " />
            <img class="box_fujianimg"
                 src="../../../assets/image/enter/wd.png"
                 alt=""
                 v-else />
            <div class="box_fujian">
              <h4>{{ item.attachmentTypeName }}</h4>
              <p style="
                  display: block;
                  word-break: keep-all;
                  white-space: nowrap;
                  overflow: hidden;
                  text-overflow: ellipsis;
                ">
                附件描述：{{ item.description }}
              </p>
              <p>文件到期日：{{ item.expireDate }}</p>
            </div>
            <div class="fileoperation">
              <i @click="editfileBox(item, index)">修改</i>
              <i v-if="item.attachmentType === '7'"
                 @click="delfileBox(index)">删除</i>
            </div>
          </div>
        </div>
      </div> -->

      <!-- 底部 -->
      <div class="botton">
        <div class="submit-options">
          <div @click="saveLeave">保存离开</div>
          <div @click="okSubmit">提交预览</div>
        </div>
      </div>
    </div>
    <div class="max_right">
      <a-anchor :getContainer="getContainer">
        <a-anchor-link href="#top1"
                       title="企业信息" />
        <a-anchor-link href="#top2"
                       title="业务信息"
                       v-if="currentType === 3" />
        <a-anchor-link href="#top3"
                       title="联系人信息" />
        <a-anchor-link href="#top4"
                       title="地址" />
        <a-anchor-link href="#top5"
                       title="银行卡信息"
                       v-if="this.currentType === 3" />
        <a-anchor-link href="#top6"
                       title="开票信息" />
      </a-anchor>
    </div>

    <!-- //组件新增联系人 -->
    <RoleEditForm ref="addLinkmanRuleForm"
                  :visible="addLinkman"
                  @confirmLinkman="confirmLinkman"
                  @cancel="addLinkman = false" />
    <!-- 地址组件 -->
    <AddressForm ref="addressRuleForm"
                 :visible.sync="address"
                 @confirmAddress="confirmAddress"
                 @cancel="address = false" />
    <!-- 银行卡信息组件 -->
    <BankcardForm ref="bankcardRuleForm"
                  :visible="bankcard"
                  @confirmBankCard="confirmBankCard"
                  @cancel="bankcard = false" />

    <!-- 公司附件 -->
    <FirmfileForm ref="fileRuleForm"
                  :visible="fileUoload"
                  @confirmFileUpload="confirmFileUpload"
                  @cancel="fileUoload = false" />
  </div>
</template>
<script>
import RoleEditForm from "./components/linkman-add";
import AddressForm from "./components/address-add";
import BankcardForm from "./components/bankcard-add";
import FirmfileForm from "./components/firmfile-add";
import setting from "@/settings.js";
import { TreeSelect } from "ant-design-vue";
import multipleSelect from '@/components/common/multipleSelect';

const SHOW_PARENT = TreeSelect.SHOW_PARENT;
const treeData = [];
export default {
  name: "RoleList",
  components: { RoleEditForm, AddressForm, BankcardForm, FirmfileForm, multipleSelect },
  data () {
    return {
      loading: false,
      //供应商数据信息
      enterpriseInformationArr: [],
      value: undefined,
      treeData,
      SHOW_PARENT,
      replaceFields: {
        children: "children",
        title: "name",
        key: "name",
        value: "id",
      },
      // 上传地址
      uploadUrl: setting.uploadUrl,
      // 预览地址
      previewUrl: setting.previewUrl,

      //新增联系人组件
      addLinkman: false,
      //当前修改联系人的下标
      editLinkmanIndex: "",
      //联系人组件 true为新增 false 为编辑
      clickLinkmanStatus: "",

      //地址组件是否显示
      address: false,
      //当前修改地址的下标
      editAddressIndex: "",
      //地址组件 true为新增 false 为编辑
      clickAddressStatus: "",

      //银行卡组件是否显示
      bankcard: false,
      //当前修改银行卡的下标
      editBankCardIndex: "",
      //银行卡组件 true为新增 false 为编辑
      clickBankCardStatus: "",

      //文件组件是否显示
      fileUoload: false,
      //当前修改文件的下标
      editFileUploadUIndex: "",
      //上传文件组件 true为新增 false 为编辑
      clickFileUploadStatus: "",

      imageUrl: "",
      labelCol: { span: 3 },
      wrapperCol: { span: 11 },
      labelCol1: { span: 5 },
      wrapperCol1: { span: 16 },
      labelCol2: { span: 4 },
      wrapperCol2: { span: 16 },
      //选中的详细地址list
      selectAddressArr: [],
      //品牌列表
      productList: [],
      //省市区列表
      CityArray: [],
      //api地区数据
      apiData: {},
      //api默认选中地址
      apiAddress: {},
      // 服务范围的下拉数据
      servicesArea: [],
      // 服务范围的选中数据
      deliveries: [],
      formArr: '',
      form: {
        // 营业执照照片
        businessLicensePicId: '',
        // 身份证正面
        idCardFrontPicId: '',
        // 身份证背面
        idCardBackPicId: '',
        legalPersonMobile: '',
        //详细地址
        address: "",
        shortName: '',
        //审核状态 0草稿 1审批中 2通过 3驳回 4撤销
        auditStatus: "",
        //审核状态名称
        auditStatusName: "",
        //经营品牌ID
        brandId: undefined,
        //经营品牌
        brand: "",
        //企业类型，0-公司，1-社会组织 ，3-香港公司，4-事业单位，6-基金会，7-医院，8-海外公司，9-律师事务所，10-学校 ，-1-其他
        entType: "",
        //企业类型名称
        entTypeName: "",
        //成立日期
        foundDate: "",
        // /企业扩展信息ID
        id: "",
        //法人
        legalPerson: "",
        //企业全称
        name: "",
        //所属地区
        province: "",
        //注册资本（万）
        regCapital: "",
        //经营范围
        scope: "",
        //联系人
        tenantContacts: [],
        //地址
        tenantAddresses: [],
        //附件信息
        tenantAttachments: [],
        //银行卡
        tenantBanks: [],
        //开票信息
        tenantInvoice: {
          //发票抬头
          title: "",
          //税务登记号
          taxRegNo: "",
          //开户行
          bankAccount: "",
          //开户行账号
          accountName: "",
          //税务登记地址
          taxRegAddr: "",
          //税务登记电话
          taxRegTel: "",
          //收票人邮箱
          acceptEmail: "",
          //收票人手机号
          acceptMobile: "",
          //收票人详细地址
          acceptAddr: "",
          //省
          province: "",
          //省编码
          provinceCode: "",
          //市
          city: "",
          //市编码
          cityCode: "",
          //区
          district: "",
          //区编码
          districtCode: "",
          //街道
          street: "",
          //街道编码
          streetCode: "",
          //选中地址列表
          optionsA: [],
        },
        //供应商组织类型
        orgType: 1,
        //供应商组织类型名称
        orgTypeName: "",
        masterCategory: '',
        assistCategory: '',
        // 送货服务范围
        deliveries: "",
        //公司logo
        logo: "",
        //公司简介
        introduction: "",
      },
    };
  },
  methods: {
    // 初始化数据
    initData () {
      this.$set(this, 'form', {
        // 营业执照照片
        businessLicensePicId: '',
        // 身份证正面
        idCardFrontPicId: '',
        // 身份证背面
        idCardBackPicId: '',
        legalPersonMobile: '',
        //详细地址
        address: "",
        shortName: '',
        //审核状态 0草稿 1审批中 2通过 3驳回 4撤销
        auditStatus: "",
        //审核状态名称
        auditStatusName: "",
        //经营品牌ID
        brandId: undefined,
        //经营品牌
        brand: "",
        //企业类型，0-公司，1-社会组织 ，3-香港公司，4-事业单位，6-基金会，7-医院，8-海外公司，9-律师事务所，10-学校 ，-1-其他
        entType: "",
        //企业类型名称
        entTypeName: "",
        //成立日期
        foundDate: "",
        // /企业扩展信息ID
        id: "",
        //法人
        legalPerson: "",
        //企业全称
        name: "",
        //所属地区
        province: "",
        //注册资本（万）
        regCapital: "",
        //经营范围
        scope: "",
        //联系人
        tenantContacts: [],
        //地址
        tenantAddresses: [],
        //附件信息
        tenantAttachments: [],
        //银行卡
        tenantBanks: [],
        //开票信息
        tenantInvoice: {
          //发票抬头
          title: "",
          //税务登记号
          taxRegNo: "",
          //开户行
          bankAccount: "",
          //开户行账号
          accountName: "",
          //税务登记地址
          taxRegAddr: "",
          //税务登记电话
          taxRegTel: "",
          //收票人邮箱
          acceptEmail: "",
          //收票人手机号
          acceptMobile: "",
          //收票人详细地址
          acceptAddr: "",
          //省
          province: "",
          //省编码
          provinceCode: "",
          //市
          city: "",
          //市编码
          cityCode: "",
          //区
          district: "",
          //区编码
          districtCode: "",
          //街道
          street: "",
          //街道编码
          streetCode: "",
          //选中地址列表
          optionsA: [],
        },
        //供应商组织类型
        orgType: 1,
        //供应商组织类型名称
        orgTypeName: "",
        //经营品类ID
        masterCategory: '',
        assistCategory: '',
        // 送货服务范围
        deliveries: "",
        //公司logo
        logo: "",
        //公司简介
        introduction: "",
      });
    },
    getContainer () {
      return document.getElementById('scroll-container')
    },
    // 获取服务范围的下级区域的数据
    getServicesAreaChild ({ i, fn }) {
      let list = this.servicesArea;
      this.$store.dispatch('unSave/getAreaListSync', {
        code: list[i].code,
        level: list[i].level
      }).then(result => {
        for (let i = 0; i < result.length; i++) {
          result[i].label = result[i].name;
          result[i].value = result[i].code;
        }
        fn ? fn({ result, i }) : '';
      })
    },
    //获取4s/供应商企业信息数据
    getEnterpriseInformation () {
      let url = '';
      this.$store.dispatch('user/toFilterUserTenants').then(() => {
        let Id = JSON.parse(localStorage.getItem('vuex')).user.currentTenant.id
        if (this.currentType === 2) {
          url = this.$api.register.get4sDetail(Id);
        } else {
          url = this.$api.register.getSupplierDetail(Id);
        }
        this.$store.dispatch("request", url).then((res) => {
          let result = res.result;
          console.log(result);
          if (result.tenantInvoice) {
            //获取选中详细地址
            this.getadress2(result);
            this.setApiAddress(result);
          }
          result.tenantInvoice = result.tenantInvoice || {}
          this.deliveries = result.deliveries || []
          this.form = result
          //2 4s回显   3 供应商回显
          if (this.currentType === 2) {
            // this.form =
          } else {
            //入伙没有组织类型 默认给1
            if (this.form.orgType === null) {
              this.form.orgType = 1
            } else {
              this.form.orgType = Number(this.form.orgType)
            }
            this.form.masterCategory = Number(this.form.masterCategory)
            this.form.assistCategory = Number(this.form.assistCategory)
          }
          this.enterpriseInformationArr = result;
          if (this.enterpriseInformationArr.foundDate) {
            this.enterpriseInformationArr.foundDate = this.enterpriseInformationArr.foundDate.split(
              " "
            )[0];
          }
          if (this.enterpriseInformationArr.termStart) {
            this.enterpriseInformationArr.termStart = this.enterpriseInformationArr.termStart.split(
              " "
            )[0];
          }
          if (this.enterpriseInformationArr.termEnd) {
            this.enterpriseInformationArr.termEnd = this.enterpriseInformationArr.termEnd.split(
              " "
            )[0];
          } else {
            this.enterpriseInformationArr.termEnd = "不约定期限";
          }
        });
      })

    },
    setApiAddress (result) {
      this.apiAddress.province = result.tenantInvoice.provinceCode;
      this.apiAddress.city = result.tenantInvoice.cityCode;
      this.apiAddress.district = result.tenantInvoice.districtCode;
    },
    //获取商品品牌列表
    getCommodityBrand () {
      let data = {
        pageNo: "1",
        pageSize: "1000000",
      };
      this.$store
        .dispatch("request", this.$api.register.getProductList(data))
        .then((res) => {
          let result = res.result.records;
          this.productList = result;
          console.log(this.productList);
        });
    },
    //获取品类
    // getCategory () {
    //   let data = {
    //     categoryId: "",
    //     keywords: "",
    //   };
    //   this.$store
    //     .dispatch("request", this.$api.register.getcategory(data))
    //     .then((res) => {
    //       console.log(res);
    //       this.treeData = res.result;
    //     });
    // },
    // onchanges (value, label) {
    //   console.log(value, label);
    //   let result = []
    //   let id = JSON.parse(localStorage.getItem('vuex')).user.currentTenant.id
    //   console.log(id);
    //   value.forEach((element, key) => {
    //     result.push({
    //       categoryId: element,
    //       categoryName: label[key],
    //       tenantId: id
    //     })
    //   });
    //   this.form.relationCategoryTenants = result
    // },

    // 营业执照
    businessLicensePicChange (val) {
      if (val.file.status === 'done') {
        this.form.businessLicensePicId = val.file.response.result;
        // 如果上传成功图片则识别营业执照
        // if (this.form.businessLicensePicId) {
        //   this.$store.dispatch('settleIn/distinguishBusinessLicense', this.form.businessLicensePicId).then(res => {
        //     this.form.tenantName = res.name;
        //     this.form.address.detailAddr = res.address;
        //     this.form.legalPerson = res.operName;
        //     this.form.creditCode = res.creditCode;
        //   })
        // }
      }
    },
    // 身份证正面照
    idCardFrontPicChange (val) {
      console.log(val);
      if (val.file.status === 'done') {
        this.form.idCardFrontPicId = val.file.response.result;
        // 如果证件照正面上传成功则识别证件照
        // if (this.form.idCardFrontPicId) {
        //   this.$store.dispatch('settleIn/distinguishIdCard', this.form.idCardFrontPicId).then(res => {
        //     console.log(res);
        //     if (!this.form.legalPerson && res.name) this.form.legalPerson = res.name;
        //     if (!this.form.contact && res.name) this.form.contact = res.name;
        //     if (res.no) this.form.legalPersonIdCard = res.no;
        //   })
        // }
      }
    },
    // 身份证背面照片
    idCardBackPicChange (val) {
      console.log(val);
      if (val.file.status === 'done') {
        this.form.idCardBackPicId = val.file.response.result;
      }
    },
    // 删除图片
    delImage (key) {
      console.log(this.form, key);
      this.$set(this.form, key, '');
    },
    // beforeUpload (file) {
    //   const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
    //   if (!isJpgOrPng) {
    //     this.$message.error('请上传JPG或者PNG格式的图片');
    //   }
    //   // const isLt2M = file.size / 1024 / 1024 < 2;
    //   // if (!isLt2M) {
    //   //   this.$message.error('请上传2M以内的图片!');
    //   // } && isLt2M
    //   return isJpgOrPng;
    // },


    //获取选中省市区的详情
    getadress2 (result) {
      let requestData = {
        district: result.tenantInvoice.districtCode,
        city: result.tenantInvoice.cityCode,
        province: result.tenantInvoice.provinceCode,
      };
      for (let i in requestData) {
        this.apiRequest(requestData[i], i, result);
      }
    },
    apiRequest (code, type, result) {
      console.log(code, type, 'a1');
      this.$store
        .dispatch("unSave/getAreaListSync", {
          code,
          level: type
        })
        .then((res) => {
          this.apiData[type] = res
          this.apiCallBack(result);
        });
    },
    apiCallBack (result) {
      console.log(this.apiData)
      if (Object.keys(this.apiData).length === 3) {
        let districtData = this.formatOptions(this.apiData.district);
        let cityData = this.formatOptions(this.apiData.city);
        cityData = this.addChildren(
          cityData,
          this.apiAddress.district,
          districtData
        );
        let provinceData = this.formatOptions(this.apiData.province);
        provinceData = this.addChildren(
          provinceData,
          this.apiAddress.city,
          cityData
        );
        let options = this.CityArray;
        options = this.addChildren(
          options,
          this.apiAddress.province,
          provinceData
        );
        this.CityArray = [...options];
        let optionsA = [];
        optionsA.push(result.tenantInvoice.provinceCode);
        optionsA.push(result.tenantInvoice.cityCode);
        optionsA.push(result.tenantInvoice.districtCode);
        optionsA.push(result.tenantInvoice.streetCode);
        this.$set(this.form.tenantInvoice, 'optionsA', optionsA);
      }
    },
    addChildren (options, code, childrenData) {
      options.forEach((element) => {
        if (element.code === code) {
          element.children = childrenData;
        }
      });
      return options;
    },
    formatOptions (array) {
      array.map(function (value) {
        value.label = value.name;
        value.value = value.code;
        return value;
      });
      return array;
    },
    //新建联系人
    confirmLinkman (updateData) {
      console.log(updateData);
      this.addLinkman = false;
      //如果编辑下标不为空 则是编辑 要修改下标对应数组与默认状态
      if (this.clickLinkmanStatus === false) {
        let defaultItem = "";
        let changeDefault = updateData.beDefault;
        this.form.tenantContacts[this.editLinkmanIndex] = updateData;
        if (changeDefault) {
          for (let i = 0; i < this.form.tenantContacts.length; i++) {
            if (i !== this.editLinkmanIndex) {
              this.form.tenantContacts[i].beDefault = false;
            } else {
              defaultItem = this.form.tenantContacts[i];
            }
          }
          this.form.tenantContacts.splice(this.editLinkmanIndex, 1);
          this.form.tenantContacts.unshift(defaultItem);
        }
      } else {
        //如果下标为空 是新建 要先判断新建的默认状态 并改变数组其他默认状态
        if (updateData.beDefault) {
          if (this.form.tenantContacts !== null) {
            for (let i = 0; i < this.form.tenantContacts.length; i++) {
              this.form.tenantContacts[i].beDefault = false;
            }
            this.form.tenantContacts.unshift(updateData);
          } else {
            this.form.tenantContacts = []
            this.form.tenantContacts.push(updateData);
          }
        } else {
          this.form.tenantContacts.push(updateData);
        }
      }
    },
    addlinkman () {
      this.addLinkman = true;
      //判断是否是第一次
      this.$refs.addLinkmanRuleForm.contactSavedtos(this.form.tenantContacts);
      this.clickLinkmanStatus = true;
    },
    //设置默认联系人
    clickDefault (index) {
      for (let i = 0; i < this.form.tenantContacts.length; i++) {
        this.form.tenantContacts[i].beDefault = false;
        this.form.tenantContacts[index].beDefault = true;
      }
      let defaultItem = this.form.tenantContacts[index];
      this.form.tenantContacts.splice(index, 1);
      this.form.tenantContacts.unshift(defaultItem);
    },
    //修改联系人
    editLinkman (item, index) {
      this.addLinkman = true;
      this.editLinkmanIndex = index;
      this.clickLinkmanStatus = false;
      this.$refs.addLinkmanRuleForm.getList(item);
    },
    //删除联系人
    delDefault (index) {
      this.form.tenantContacts.splice(index, 1);
    },
    //新建地址
    confirmAddress (updateData) {
      this.address = false;
      //如果编辑下标不为空 则是编辑 要修改下标对应数组与默认状态
      if (this.clickAddressStatus === false) {
        let defaultItem = "";
        let changeDefault = updateData.beenDefault;
        this.form.tenantAddresses[this.editAddressIndex] = updateData;
        if (changeDefault) {
          for (let i = 0; i < this.form.tenantAddresses.length; i++) {
            if (i !== this.editAddressIndex) {
              this.form.tenantAddresses[i].beenDefault = false;
            } else {
              defaultItem = this.form.tenantAddresses[i];
            }
          }
          this.form.tenantAddresses.splice(this.editAddressIndex, 1);
          this.form.tenantAddresses.unshift(defaultItem);
        }
      } else {
        //如果下标为空 是新建 要先判断新建的默认状态 并改变数组其他默认状态
        if (updateData.beenDefault) {
          if (this.form.tenantAddresses !== null) {
            for (let i = 0; i < this.form.tenantAddresses.length; i++) {
              this.form.tenantAddresses[i].beenDefault = false;
            }
            this.form.tenantAddresses.unshift(updateData);
          } else {
            this.form.tenantAddresses = []
            this.form.tenantAddresses.push(updateData)
          }
        } else {
          this.form.tenantAddresses.push(updateData);
        }
      }
    },
    //新建地址按钮按钮
    addAddress () {
      (this.address = true),
        //哦安短是否是第一次
        this.$refs.addressRuleForm.tenantAddress(this.form.tenantAddresses);
      this.clickAddressStatus = true;
    },
    //修改地址
    editAddress (item, index) {
      this.address = true;
      this.editAddressIndex = index;
      this.clickAddressStatus = false;
      this.$refs.addressRuleForm.getList(item);
    },
    //设置默认地址
    clickBeenDefault (index) {
      for (let i = 0; i < this.form.tenantAddresses.length; i++) {
        this.form.tenantAddresses[i].beenDefault = false;
        this.form.tenantAddresses[index].beenDefault = true;
      }
      let masterItem = this.form.tenantAddresses[index];
      this.form.tenantAddresses.splice(index, 1);
      this.form.tenantAddresses.unshift(masterItem);
    },
    //删除
    delAddress (index) {
      this.form.tenantAddresses.splice(index, 1);
    },

    //新建银行卡
    confirmBankCard (updateData) {
      this.bankcard = false;
      //如果编辑下标不为空 则是编辑 要修改下标对应数组与默认状态
      if (this.clickBankCardStatus === false) {
        let defaultItem = "";
        let changeDefault = updateData.master;
        this.form.tenantBanks[this.editBankCardIndex] = updateData;
        if (changeDefault) {
          for (let i = 0; i < this.form.tenantBanks.length; i++) {
            if (i != this.editBankCardIndex) {
              this.form.tenantBanks[i].master = false;
            } else {
              defaultItem = this.form.tenantBanks[i];
            }
          }
          this.form.tenantBanks.splice(this.editBankCardIndex, 1);
          this.form.tenantBanks.unshift(defaultItem);
        }
      } else {
        //如果下标为空 是新建 要先判断新建的默认状态 并改变数组其他默认状态
        console.log("新增一条");
        if (updateData.master) {
          if (this.form.tenantBanks !== null) {
            for (let i = 0; i < this.form.tenantBanks.length; i++) {
              this.form.tenantBanks[i].master = false;
            }
            this.form.tenantBanks.unshift(updateData);
          } else {
            this.form.tenantBanks = []
            this.form.tenantBanks.push(updateData)
          }
        } else {
          this.form.tenantBanks.push(updateData);
        }
      }
    },
    //新建银行按钮
    addbankcard () {
      (this.bankcard = true),
        //哦安短是否是第一次
        this.$refs.bankcardRuleForm.tenantBank(this.form.tenantBanks);
      this.clickBankCardStatus = true;
    },
    //修改银行卡
    editBankCard (item, index) {
      this.bankcard = true;
      this.editBankCardIndex = index;
      this.clickBankCardStatus = false;
      this.$refs.bankcardRuleForm.getList(item);
    },
    //设置默认银行卡
    clickMaster (index) {
      for (let i = 0; i < this.form.tenantBanks.length; i++) {
        this.form.tenantBanks[i].master = false;
        this.form.tenantBanks[index].master = true;
      }
      let masterItem = this.form.tenantBanks[index];
      this.form.tenantBanks.splice(index, 1);
      this.form.tenantBanks.unshift(masterItem);
      console.log([index], "this.editLinkmanIndex");
      console.log(this.form.tenantBanks, "this.form.tenantBanks");
    },
    //删除
    delMaster (index) {
      this.form.tenantBanks.splice(index, 1);
      console.log(this.form.tenantBanks, "");
    },

    //新建附件
    confirmFileUpload (updateData) {
      this.fileUoload = false;
      //如果编辑下标不为空 则是编辑 要修改下标对应数组与默认状态
      if (this.clickFileUploadStatus === false) {
        this.form.tenantAttachments[this.editFileUploadUIndex] = updateData;
      } else {
        //如果下标为空 是新建 要先判断新建的默认状态 并改变数组其他默认状态
        if (updateData.attachmentType === "1") {
          updateData.description = updateData.describe;
        }
        let tenantAttachments = this.form.tenantAttachments ? this.form.tenantAttachments : [];
        tenantAttachments.push(updateData);
        this.$set(this.form, 'tenantAttachments', tenantAttachments);
      }
    },
    //新建附件按钮
    addfileupload () {
      this.fileUoload = true;
      //判断是否是第一次
      this.$refs.fileRuleForm.tenantAttachment(this.form.tenantAttachments);
      this.clickFileUploadStatus = true;
    },
    //修改附件
    editfileBox (item, index) {
      this.fileUoload = true;
      this.editFileUploadUIndex = index;
      this.clickFileUploadStatus = false;
      this.$refs.fileRuleForm.getList(item);
    },
    //删除附件
    delfileBox (index) {
      let formDate = new FormData();
      formDate.append(
        "attachmentId",
        this.form.tenantAttachments[index].attachmentId
      );
      this.$store
        .dispatch("request", this.$api.register.getdeletFile(formDate))
        .then((res) => {
          console.log(res);
          this.form.tenantAttachments.splice(index, 1);
        });
    },

    //获取省市区 如果存的没有就走接口获取再存起来 如果有就直接拿存的赋值
    getCity (fn) {
      console.log('a2')
      this.$store.dispatch("unSave/getAreaListSync", {}).then((result) => {
        for (let i = 0; i < result.length; i++) {
          result[i].isLeaf = false;
          result[i].label = result[i].name;
          result[i].value = result[i].code;
          delete result[i].children;
          this.$set(result[i], 'isChecked', false);
        }
        this.CityArray = result;
        this.servicesArea = result.length > 0 ? JSON.parse(JSON.stringify(result)) : [];
        if (fn) fn();
      });
    },
    loadData (selectedOptions) {
      this.selectAddressArr = selectedOptions;
      const targetOption = selectedOptions[selectedOptions.length - 1];
      if (targetOption.level !== "street") {
        targetOption.loading = true;
        console.log(targetOption.code, targetOption.level, 'a3')
        this.$store
          .dispatch("unSave/getAreaListSync", {
            code: targetOption.code,
            level: targetOption.level,
          })
          .then((res) => {
            let result = res;
            for (let i = 0; i < result.length; i++) {
              result[i].isLeaf = result[i].level === "street";
              result[i].label = result[i].name;
              result[i].value = result[i].code;
              delete result[i].children;
            }
            console.log(result);
            targetOption.children = result;
            if (result.length === 0) {
              targetOption.isLeaf = true;
            }
            targetOption.loading = false;
            this.CityArray = [...this.CityArray];
          });
      }
    },
    onChangeAddress (val) {
      if (val.length === 0) {
        this.addressArr();
      }
      for (let i = 0; i < this.selectAddressArr.length; i++) {
        if (this.selectAddressArr[i].level === "province") {
          this.form.tenantInvoice.province = this.selectAddressArr[i].label;
          this.form.tenantInvoice.provinceCode = this.selectAddressArr[i].value;
        }
        if (this.selectAddressArr[i].level === "city") {
          this.form.tenantInvoice.city = this.selectAddressArr[i].label;
          this.form.tenantInvoice.cityCode = this.selectAddressArr[i].value;
        }
        if (this.selectAddressArr[i].level === "district") {
          this.form.tenantInvoice.district = this.selectAddressArr[i].label;
          this.form.tenantInvoice.districtCode = this.selectAddressArr[i].value;
        }
      }
      if (val.length === 4) {
        console.log('a4')
        this.$store
          .dispatch("unSave/getAreaListSync", {
            code: this.form.tenantInvoice.districtCode,
            level: this.form.tenantInvoice.district,
          })
          .then((data) => {
            for (let i = 0; i < data.length; i++) {
              if (data[i].value === val[3]) {
                this.form.tenantInvoice.street = data[i].name;
                this.form.tenantInvoice.streetCode = data[i].value;
                this.form.tenantInvoice.optionsA = val;
                this.$forceUpdate();
              }
            }
          });
      }
    },

    okSubmit () {
      this.form.auditStatus = '0';
      //2 4s 3供应商

      if (this.currentType === 2) {
        this.submiturl();
      } else {
        console.log(this.form);
        this.$refs.ruleForm1.validate((valid) => {
          console.log(valid);
          if (valid) {
            this.supplierSubmit();
          }
        })


      }
    },
    //4s提交预览
    submiturl () {
      this.messageArr1('4s');

    },
    //供应商提交预览
    supplierSubmit () {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.messageArr1('供应商');
        }
      })
    },

    //判断基础信息
    messageArr1 (e) {
      if (this.form.shortName == null || this.form.shortName == '') {
        this.$message.error('请输入企业简称！');
        return;
      }
      if (this.form.legalPersonMobile == null || this.form.legalPersonMobile == '') {
        this.$message.error('请输入法人联系方式！');
        return;
      }
      let reg = /^1[3456789]\d{9}$/
      if (!reg.test(this.form.legalPersonMobile)) {
        this.$message.error('请输入正确的法人联系方式！');
        return;
      }
      console.log(123123123, '123');
      if (this.form.idCardFrontPicId == '' || this.form.idCardFrontPicId == null) {
        this.$message.error('请上传法人身份证正面照！');
        return;
      }
      if (this.form.idCardBackPicId == '' || this.form.idCardBackPicId == null) {
        this.$message.error('请上传法人身份证国徽照！');
        return;
      }
      if (this.form.businessLicensePicId == '' || this.form.businessLicensePicId == null) {
        this.$message.error('请上传营业执照！');
        return;
      }

      if (e === '供应商') {
        if (this.form.brandId == '') {
          this.$message.error('请选择供应商！');
          return;
        }
        this.messageArr();
      }
      if (e === '4s') {
        this.valuation()
        this.form.tenantId = this.enterpriseInformationArr.tenantId;
        this.messageArr();
      }
    },

    //判断联系人地址 银行卡是否又数据
    messageArr () {
      let Status = true
      let message = {};
      if (this.currentType === 2) {
        message = {
          tenantContacts: '请添加联系人信息',
          tenantAddresses: '请添加地址信息',
        };
      } else if (this.currentType === 3) {
        message = {
          tenantContacts: '请添加联系人信息',
          tenantAddresses: '请添加地址信息',
          tenantBanks: '请添加银行卡信息',
        };
      }
      for (let key in message) {
        if (!this.form[key]) {
          this.$message.error(message[key]);
          Status = false
          break;
        }
      }
      if (Status) {
        if (this.currentType === 3) {
          this.categoryArr()
          this.$store.dispatch("request", this.$api.register.getSaveSupplier(this.formArr))
            .then(() => {
              this.$router.push('/enter/enterView/supplierPreview');
            });
        }

        if (this.currentType === 2) {

          console.log(this.formArr);
          this.$store
            .dispatch("request", this.$api.register.get4sSubmit(this.formArr))
            .then(() => {
              this.$message.success("保存成功");
              this.$router.push("/enter/enterView/supplierPreview");
            });
        }
      }
    },
    //供应商入参调整转换
    categoryArr () {
      console.log(this.form);
      let orgTypeNameList = ['汽配商', '品牌一级代理商', '品牌二级代理商'];
      this.form.orgTypeName = orgTypeNameList[this.form.orgType - 1];
      this.form.deliveries = this.deliveries
      this.form.tenantId = this.enterpriseInformationArr.tenantId;
      this.valuation()
    },
    //暂存
    saveLeave () {
      this.form.auditStatus = '0';
      // 在这里把不要的参数全删了 你先改着
      if (this.currentType === 2) {
        this.form.tenantId = this.enterpriseInformationArr.tenantId;
        this.valuation()
        console.log(this.formArr);
        if (this.formArr.invoiceSaveDTO.title === undefined) {
          this.formArr.invoiceSaveDTO = null
        }
        this.$store
          .dispatch("request", this.$api.register.get4sSubmit(this.formArr))
          .then(() => {
            this.$message.success("保存成功");

          });
      } else {
        this.form.tenantId = this.enterpriseInformationArr.tenantId;
        this.categoryArr()
        if (this.formArr.invoiceSaveDTO.title === undefined) {
          this.formArr.invoiceSaveDTO = null
        }
        this.$store.dispatch("request", this.$api.register.getSaveSupplier(this.formArr))
          .then(() => {
            this.$message.success("保存成功");
          });
      }
    },
    //选择经营品牌
    productHandleChange (e) {
      console.log(e);
      for (let i = 0; i < this.productList.length; i++) {
        if (this.productList[i].id === e) {
          this.form.brand = this.productList[i].name;
          this.form.brandId = this.productList[i].id;
        }
      }
    },
    //logo上传前
    beforeUpload (file) {
      const isJpgOrPng =
        file.type === "image/jpeg" || file.type === "image/png" || file.type === "image/jpg";
      if (!isJpgOrPng) {
        this.$message.error("You can only upload JPG file!");
      }
      return isJpgOrPng;
    },
    //logo上传
    handleChange (val) {
      this.loading = true;
      console.log(val);
      if (val.file.status === "done") {
        this.form.logo = val.file.response.result;
        this.loading = false;
      }
    },

    //供应商组织类型
    orgTypeOnchange (e) {
      console.log(e);
      console.log(this.form.orgType);
    },

    //企业信息赋值
    valuation () {
      const array = ['address', 'auditStatus', 'auditStatusName', 'entType', 'entTypeName', 'foundDate', 'id', 'legalPerson', 'name', 'regCapital', 'scope', 'shortName', 'legalPersonMobile', 'idCardBackPicId', 'idCardFrontPicId', 'businessLicensePicId'];
      for (let item of array) {
        this.$set(this.form, item, this.enterpriseInformationArr[item]);
      }

      this.form.contactSaveDTOS = this.form.tenantContacts;
      this.form.addressSaveDTOS = this.form.tenantAddresses;
      this.form.bankSaveDTOS = this.form.tenantBanks;
      this.form.invoiceSaveDTO = this.form.tenantInvoice;
      this.form.attachmentSaveDTOS = this.form.tenantAttachments;
      console.log('xxxxxxaaa', this.form)
      if (this.currentType === 3) {
        // this.form.categoryTenants = this.form.relationCategoryTenants
        this.form.deliverySaveDTOS = this.form.deliveries
      }
      let form = JSON.parse(JSON.stringify(this.form));
      delete form.tenantContacts
      delete form.tenantAddresses
      delete form.tenantBanks
      delete form.tenantInvoice
      delete form.tenantAttachments
      // delete form.relationCategoryTenants
      delete form.deliveries
      this.formArr = form
    },
    //清空开票信息地址值
    addressArr () {
      for (let key in this.form.tenantInvoice) {
        if (key === 'optionsA') {
          this.form.tenantInvoice.optionsA = [];
        }
      }
    },
  },
  activated () {
    this.initData();
    this.getCommodityBrand();
    this.getCity(this.getEnterpriseInformation);
    if (this.currentType === 3) {
      // this.getCategory();
    }
  },
  computed: {
    // 24s店 3供应商
    currentType () {
      return this.$store.state.settleIn.currentType;
    },
    currentTenant () {
      return this.$store.state.user.currentTenant;
    },
    rules () {
      // currentType =2 为4s   3为供应商
      if (this.currentType === 2) {
        return {
          brandId: [{ required: true, message: "请选择品牌" }],
          "tenantInvoice.title": [
            { required: true, message: "请输入发票抬头" },
          ],
          "tenantInvoice.taxRegNo": [
            { required: true, message: "请输入税务登记号" },
          ],
          "tenantInvoice.bankAccount": [
            { required: true, message: "请输入开户行" },
          ],
          "tenantInvoice.accountName": [
            { required: true, message: "请输入发票抬头" },
          ],
          "tenantInvoice.taxRegAddr": [
            { required: true, message: "请输入税务登记地址" },
          ],
          "tenantInvoice.taxRegTel": [
            { required: true, message: "请输入税务登记电话" },
            {
              pattern: /^(0\d{2,3}-?\d{7,8})|(1[3456789]\d{9})$/,
              message: "请输入正确税务登记电话",
            },
          ],
          "tenantInvoice.acceptMobile": [
            { required: true, message: "请输入收票人手机号" },
            { pattern: /^1[3456789]\d{9}$/, message: "请输入正确收票人手机号" },
          ],
          "tenantInvoice.optionsA": [
            { required: true, message: "请选择所在区域" },
          ],
          "tenantInvoice.acceptAddr": [
            { required: true, message: "请输入详细地址" },
          ],
        };
      } else {
        return {
          orgType: [{ required: true, message: "请选择组织类型" }],
          logo: [{ required: true, message: "请上传公司logo" }],
          masterCategory: [{ required: true, message: "请选择主营品类" }],
          // deliveries: [{ required: true, message: "请选择送货服务范围" }],
          "tenantInvoice.title": [
            { required: true, message: "请输入发票抬头" },
          ],
          "tenantInvoice.taxRegNo": [
            { required: true, message: "请输入税务登记号" },
          ],
          "tenantInvoice.bankAccount": [
            { required: true, message: "请输入开户行" },
          ],
          "tenantInvoice.accountName": [
            { required: true, message: "请输入发票抬头" },
          ],
          "tenantInvoice.taxRegAddr": [
            { required: true, message: "请输入税务登记地址" },
          ],
          "tenantInvoice.taxRegTel": [
            { required: true, message: "请输入税务登记电话" },
            {
              pattern: /^(0\d{2,3}-?\d{7,8})|(1[3456789]\d{9})$/,
              message: "请输入正确税务登记电话",
            },
          ],
          "tenantInvoice.acceptMobile": [
            { required: true, message: "请输入收票人手机号" },
            { pattern: /^1[3456789]\d{9}$/, message: "请输入正确收票人手机号" },
          ],
          "tenantInvoice.optionsA": [
            { required: true, message: "请选择所在区域" },
          ],
          "tenantInvoice.acceptAddr": [
            { required: true, message: "请输入详细地址" },
          ],
        }
      }

    },
  },
};
</script>
<style lang="less" scoped>
.max {
  overflow: hidden;
  padding-left: 76px;
  margin-top: 40px;

  .max_left {
    width: 904px;
    float: left;

    .maxleftbox {
      margin-bottom: 17px;
    }

    .maxleftbox,
    .writMessage {
      border: 1px solid @greyBorder;

      .maxleft_title {
        height: 48px;
        background-color: @greyDeepBackground;
        font-size: 16px;
        line-height: 48px;
        padding-left: 16px;
        font-weight: 500;
        position: relative;
        color: @colorCommonFont;

        .addbutton {
          width: 100px;
          height: 32px;
          position: absolute;
          right: 16px;
          top: 8px;
          font-size: 12px;
          color: #3b82ff;
          text-align: center;
          line-height: 32px;
          background: #ffffff;
          border-radius: 2px;
          cursor: pointer;
        }

        i {
          font-size: 12px;
          color: @colorGreyFontM;
          font-weight: 400;
          font-style: normal;
        }
      }

      .maxleft_title1 {
        overflow: hidden;
        padding: 24px 25px 24px;

        span {
          font-size: 12px;
          color: @colorGreyFont;
          line-height: 30px;

          i {
            color: @colorCommonFont;
            font-style: normal;
            font-size: 12px;
          }
        }

        .title1_i {
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          display: inline-block;
          width: 362px;
          height: 14px;
          line-height: 19px;
        }
      }

      .invoice-info {
        padding-bottom: 0;
      }
    }

    .maxleftbox_box {
      padding: 24px;
      padding-bottom: 0;
      min-height: 150px;

      .box_li {
        width: 320px;
        height: 166px;
        border: 1px solid #e6e6e6;
        padding: 0 25px;
        display: inline-block;
        margin-right: 24px;
        margin-bottom: 24px;
        position: relative;

        .box_litop {
          height: 73px;
          padding: 17px 0;
          border-bottom: 1px solid #e6e6e6;
          position: relative;

          .box_litop_dress {
            width: 276px;
            height: 32px;
            opacity: 1;
            font-size: 12px;
            font-family: PingFangSC, PingFangSC-Regular;
            font-weight: 400;
            text-align: left;
            color: @colorCommonFont;
            line-height: 16px;
          }

          .box_litop_left {
            float: left;
            font-size: 14px;
            color: @colorCommonFont;

            p {
              margin-bottom: 0;
              font-family: PingFangSC, PingFangSC-Regular;
              font-weight: 400;
              text-align: left;
              color: @colorCommonFont;
            }
          }

          .box_litop_right {
            position: absolute;
            right: 0;
            top: 16px;
            font-family: PingFangSC, PingFangSC-Medium;
            font-weight: 500;

            span {
              font-style: normal;
              color: #999;
              font-size: 14px;
              padding-left: 16px;
            }

            i {
              font-style: normal;
              cursor: pointer;
              color: #3b82ff;
              font-size: 14px;
              padding-left: 16px;
            }
          }
        }

        .box_bottom {
          padding: 10px 0;
          overflow: hidden;
          position: relative;

          p {
            margin-bottom: 0;
            font-size: 12px;
            line-height: 24px;
            color: @colorGreyFont;
          }

          span {
            padding-left: 5px;
          }

          .bottom_left {
            float: left;

            .addressbz {
              width: 276px;
              display: block; /*内联对象需加*/
              word-break: keep-all; /* 不换行 */
              white-space: nowrap; /* 不换行 */
              overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
              text-overflow: ellipsis; /* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/
            }
          }

          .bottom_right {
            position: absolute;
            right: 20px;
          }

          .dizhi {
            position: absolute;
            right: 5px;
            bottom: 10px;
            color: #3b82ff;
            font-size: 14px;
            cursor: pointer;

            i {
              font-style: normal;
              padding-left: 16px;
            }
          }
        }

        .box_fujianimg {
          position: absolute;
          top: 20px;
          left: 25px;
          width: 40px;
          height: 40px;
        }

        .box_fujian {
          margin: 20px 0 0 50px;

          h4 {
            margin-bottom: 9px;
          }

          p {
            font-size: 12px;
            color: @colorGreyFont;
            margin-bottom: 2px;
          }
        }

        .fujian_del {
          position: absolute;
          right: 24px;
          top: 20px;
          color: #3b82ff;
          cursor: pointer;
        }
      }
    }

    .submit-options {
      width: 360px;
      margin: 0 auto;

      div {
        display: inline-block;
        width: 172px;
        height: 32px;
        border-radius: 4px;
        line-height: 32px;
        text-align: center;
        font-size: 14px;
        cursor: pointer;
      }

      div:nth-child(1) {
        background: @activeRed;
        margin-right: 16px;
        color: #fff;
      }

      div:nth-child(2) {
        background: @greyDeepBackground;
        color: @colorCommonFont;
      }
    }
  }

  .scope {
    margin-left: 62px;
    color: #333;
    font-style: normal;
    font-size: 12px;
    display: inline-block;
  }

  .uploadimg {
    font-size: 12px;
    color: #ccc;
    position: absolute;
    bottom: -30px;
  }

  .max_right {
    width: 172px;
    float: right;
  }

  .ant-upload.ant-upload-select-picture-card {
    width: 200px;
    height: 120px;
  }

  /deep/ .ant-select {
    font-size: 12px;
  }

  /deep/ .ant-select-selection--single {
    height: 28px;
  }

  /deep/ .ant-select-selection__rendered {
    line-height: 28px;
  }

  /deep/ .ant-input {
    font-size: 12px;
    color: @colorCommonFont;
  }

  /deep/ .ant-form-item-with-help {
    margin-bottom: 24px;
  }

  /deep/ .ant-form-explain {
    position: absolute;
    font-size: 12px;
  }

  /deep/ .ant-form-item-label > label {
    color: @colorGreyFont;
    font-size: 12px;
    font-family: PingFangSC, PingFangSC-Regular;
  }

  /deep/ .ant-form label {
    font-size: 12px;
    color: @colorGreyFont;
  }

  /deep/ .ant-input::placeholder {
    color: #ccc;
  }

  /deep/ .ant-form-item {
    font-size: 12px;
    margin-bottom: 20px;
  }
}

.photos3,
.photos4,
.photos5 {
  float: left;
  margin-right: 24px;
  text-align: center;
  p {
    font-size: 12px;
    color: #666;
  }
}
.photos3,
.photos4,
.photos5 {
  .avatars {
    position: absolute;
    right: 0;
    top: 0;
    z-index: 2;
    transform: translate(50%, -50%);
    cursor: pointer;
  }
}

.photos3,
.photos4,
.photos5 {
  position: relative;
  width: 200px;
  float: left;

  p {
    text-align: center;
    color: @colorGreyFont;
    font-size: 12px;

    i {
      color: #cccccc;
      font-style: normal;
    }
  }
}
.upload-image-contain {
  width: 200px;
  height: 120px;
  border: 1px solid #fff;
  margin-bottom: 6px;
  transition: border-color 0.2s;
  .flex(center, center);
  background: @greyBackground;
  cursor: pointer;

  &:hover {
    border-color: @activeRed;
  }

  .uppload-image {
    max-width: 100%;
    max-height: 100%;
  }
}
.fileoperation {
  position: absolute;
  right: 24px;
  top: 20px;

  i {
    font-size: 14px;
    color: #3b82ff;
    font-style: normal;
    cursor: pointer;
    margin-left: 16px;
  }
}
</style>
